<template>
	<view class="page">
		<web-view :src="webViewSrc"></web-view>
	</view>
</template>

<script>
	import base from '@/common/config'
	export default {
		data() {
			return {
				webViewSrc:'',
				code:'',
			}
		},
		methods: {
			getWXCode() {
							let appid = base.oaappid   //公众号的唯一标识
							let code = this.getUrlCode().code; //是否存在code
							// let url = 'https://ecard.amass.com.cn/sys/temp/tempindex'    //授权后重定向的回调链接地址
							let url = base.baseUrl +'/sys/temp/tempindex'    //授权后重定向的回调链接地址
							// let url = 'http://192.168.1.40:8080/#/pages/componentsC/visitor/visitorForm'    //授权后重定向的回调链接地址
							// if (code == null || code === "") {
							// window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+'&redirect_uri='+encodeURIComponent(url)+'&response_type=code&scope=snsapi_base&state=h5#wechat_redirect'
							window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+'&redirect_uri='+encodeURIComponent(url)+'&response_type=code&scope=snsapi_base&state=oah5#wechat_redirect'
								// this.webViewSrc = webViewSrc.trim()
							// } else {
							// 	this.code = code;
							// 	//此处调用后端提供的接口，传入获取到的code换取access_token
							// }
			 
						},
			// 截取url中的code方法
						getUrlCode() {
							// 截取url中的code方法
							var url = location.search;
							var theRequest = new Object();
							if (url.indexOf("?") != -1) {
								var str = url.substr(1);
								var strs = str.split("&");
								for (var i = 0; i < strs.length; i++) {
									theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1];
								}
							}
							return theRequest;
						}
			                        
		},
		onLoad() {
			this.getWXCode()
			// let url = 'https://ecard.amass.com.cn/sys/temp/tempindex?code=1'
			// this.webViewSrc = url.trim()
			// let reduri= encodeURIComponent("https://ecard.amass.com.cn/sys/temp/tempindex");
			// let reduri= encodeURIComponent("https://ecard.dglemin.com.cn/jeecgboot/sys/temp/tempindex");
			
			// let reduri= encodeURIComponent("https://ecard.amass.com.cn/returnPage.html");
			// wx1d6c03e999dc80d8  wx82f12530acaf959f
			// let webViewSrc = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx82f12530acaf959f&redirect_uri="+reduri+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
			// this.webViewSrc = webViewSrc.trim()
			// setTimeout(()=>{
				// uni.switchTab({
				// 	url:'/pages/index/index'
				// })
			// },500)
			
					// console.log(this.webViewSrc);
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	
}
</style>
